package com.emperor.core.logic;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.emperor.util.DateFormatter;

public class DataModelBase implements DataModel {

	protected Long crtby;
	protected Long updby;
	protected Date crtdate;
	protected Date upddate;
	private SimpleDateFormat sdf = new SimpleDateFormat(DateFormatter.YYYYMMDD);
	
	public Long getCrtby() {
		return this.crtby;
	}

	public Date getCrtdate() {
		return this.crtdate;
	}

	public Long getUpdby() {
		return this.updby;
	}

	public Date getUpddate() {
		return this.upddate;
	}

	public void setCrtby(Object crtby) {
		if (crtby != null) {
			if (crtby instanceof Long) {
				this.crtby = (Long)crtby;
			} else {
				try {
					this.crtby = new Long(crtby.toString());
				} catch(Exception e) {}
			}
		}
	}

	public void setCrtdate(Object crtdate) {
		if (crtdate != null) {
			if (crtdate instanceof Date) {
				this.crtdate = (Date)crtdate;
			} else {
				try {
					this.crtdate = sdf.parse(crtdate.toString());	
				} catch(Exception e) {}
			}
		}
	}

	public void setUpdby(Object updby) {
		if (updby != null) {
			if (updby instanceof Long) {
				this.updby = (Long)updby;
			} else {
				try {
					this.updby = new Long(updby.toString());
				} catch(Exception e) {}
			}
		}
	}

	public void setUpddate(Object upddate) {
		if (upddate != null) {
			if (upddate instanceof Date) {
				this.upddate = (Date)upddate;
			} else {
				try {
					this.upddate = sdf.parse(upddate.toString());
				} catch(Exception e) {}
			}
		}
	}

}
